package ru.spb.osll.myfit.server.parser;

import static org.junit.Assert.assertEquals;

import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;

import ru.spb.osll.myfit.common.Table;
import ru.spb.osll.myfit.common.TableStyle;

public class PageParserTest {

	private TableCreater m_parser;

	@Before
	public void setUp() {
		m_parser = new TableCreater();
	}
	
	@Test
	public void testCreateTable() {
		Table first = m_parser.createTable(TableStyle.UNKNOWN_FIXTURE,
				"enable advanced retention on clusters");
		Table second = m_parser.createTable(TableStyle.UNKNOWN_FIXTURE,
				"with cubetools", TableCreater.LINE_SEPARATOR, "write", "10",
				"files of size", "10KB", "using", "10", "threads");
		checkTables(first, second);
	}

	public void checkTables(Table first, Table second) {
		assertEquals(TableStyle.UNKNOWN_FIXTURE, first.getStyle());
		assertEquals(1, first.getData().size());
		assertEquals(1, first.getData().get(0).size());
		assertEquals("enable advanced retention on clusters", StringUtils.join(
				first.getData().get(0), "|"));

		assertEquals(TableStyle.UNKNOWN_FIXTURE, second.getStyle());
		assertEquals(2, second.getData().size());
		assertEquals("with cubetools", StringUtils.join(
				second.getData().get(0), "|"));
		assertEquals("write|10|files of size|10KB|using|10|threads",
				StringUtils.join(second.getData().get(1), "|"));

	}
}
